package zy;

public class Gongshi {
    String mc;
    String dz;
    String hm;
    String fw;
    Yuangong y[]=new Yuangong[15];
    int pos=0;
    public Gongshi(){
        for (int i=0;i<y.length;i++){
            y[i]=new Yuangong();
        }
    }
    public boolean add(Yuangong yu) {

        if (pos>y.length){
            System.out.println("人员已满");
        }
            y[pos++]=yu;

        return true;
    }
    public void show(){
        System.out.println("公司名称"+mc);
        System.out.println("注册地址"+dz);
        System.out.println("电话"+hm);
        System.out.println("经营范围"+fw);

        for (int i=0;i<y.length;i++){
            if(y[i].name==null){
                break;
            }else {
                System.out.println("工号" + y[i].gonghao);
                System.out.println("姓名" + y[i].name);
                System.out.println("性别" + y[i].sex);
                System.out.println("职务" + y[i].zhiwu);
                System.out.println("薪水" + y[i].xinshui);
                System.out.println("身份证号" + y[i].sfzh);
                System.out.println("工作年限" + y[i].gznx);
            }
        }

    }
    public boolean fire(String name) {
        for (int i = 0;i<pos;i++){
            if (y[i].name.equals(name)){
                y[i].name= null;
                for (int j = i;j<pos-1;j++){
                    y[j].gonghao = y[j+1].gonghao;
                    y[j].name = y[j+1].name;
                    y[j].sex = y[j+1].sex;
                    y[j].zhiwu = y[j+1].zhiwu;
                    y[j].xinshui = y[j+1].xinshui;
                    y[j].sfzh = y[j+1].sfzh;
                    y[j].gznx = y[j=1].gznx;
                }
                y[--pos].name = null;
                return true;
            }
        }
        return false;

    }
    public boolean addMoney(String name){
        for (int i = 0;i<pos;i++){
            if (y[i].name.equals(name)){
                for (int j = 0;j<y[i].gznx;j++){
                    y[i].xinshui+=50;
                }
            }
        }
        return true;
    }
    public void maxMoney(){
        int i = 0;
        Yuangong yu = y[0];
        for (i=0;i<pos;i++){
            if (yu.xinshui<y[i].xinshui){
                yu= y[i];
        }
        }
        System.out.println("工号" + yu.gonghao);
        System.out.println("姓名" + yu.name);
        System.out.println("性别" + yu.sex);
        System.out.println("职务" + yu.zhiwu);
        System.out.println("薪水" + yu.xinshui);
        System.out.println("身份证号" + yu.sfzh);
        System.out.println("工作年限" + yu.gznx);
    }




}
